package comoabejas

import java.net.URL;
import java.util.Date;
import java.util.List;

class Deal {
	Client client
	Area area
	Integer currentNumberOfUsers
	Integer requiredNumberOfUsers
	Integer maxNumberOfUsers //modificacion para poner un tope de compras en un deal , con 0(cero) para determinar que un deal no tiene limites
	Date voucherStartDate
	Date voucherEndDate
	String address
	Date dateOfCreation
	String title
	String details
	String conditions
	String description
	URL imageLink
	Imagen image
	Float normalPrice
	Float discountPrice
	Date startDate
	Date endDate
	String state = DealState.CREATED
	//List<Purchase> purchases
	
	//static belongsTo = Client
	
	//static hasMany = [purchases : Purchase]
	
    static constraints = {
		area(nullable:true)
		requiredNumberOfUsers(nullable:true)
		dateOfCreation(nullable:true)
		client(nullable:true)
		title(nullable:true)
		description(nullable:true)
		normalPrice(nullable:true)
		discountPrice(nullable:true)
		startDate(nullable:true)
		endDate(nullable:true)
		currentNumberOfUsers(nullable:true)
		imageLink(nullable:true)
		maxNumberOfUsers(nullable:true)
		//state(inList:DealState.getStates(), nullable:false)
    }
	
	public List getPurchases(){
		if(this.purchases == null){
			purchases = new ArrayList<Purchase>()
		}
	}
}
